var count = 0;
function bianji(obj) {
    let i2 = document.getElementsByName("sex");
    let  sex = "";
    // console.log(i2);
    if(i2[0].checked){
        sex = "男";
    }else
        sex = "女"
    let userName = document.getElementById("i3").value.trim();
    let userImg = document.getElementById("update_img");
    console.log(userImg)
    count++;
    if (count%2!=0) {
        document.getElementById("error_u").style.display = "none"
        document.getElementById("b1").style.display = "none";
        document.getElementById("b2").style.display = "none";
        document.getElementById("i1").style.display = "block";
        document.getElementById("i2").style.display = "block";
        document.getElementById("abc").innerText = "保存";
        document.getElementById("test10").onclick = function () {
            document.getElementById("test10").style.display = "block";
            document.getElementById("mm").style.display = "none";
        }
        document.getElementById("mm").onclick = function () {
            // alert(111)
            document.getElementById("test10").style.display = "block";
            document.getElementById("mm").style.display = "none";
        }



    }
    if (count%2==0){
        document.getElementById("b1").style.display = "block";
        document.getElementById("b2").style.display = "block";
        document.getElementById("i1").style.display = "none";
        document.getElementById("i2").style.display = "none";
        document.getElementById("test10").style.display = "none";
        document.getElementById("mm").style.display = "block";
        document.getElementById("abc").innerText = "编辑";
        let i1 = document.getElementById("i1").innerText;


        $.post("/mi/personal_center/personal_info2",
            {userId: parseInt(document.getElementById("userId").value.trim()),userName: userName, sex: sex,userImg: userImg.src},
            function(res){

                if(res.code=='200'){
                    //跳转

                    // console.log(res.data.userImg)
                    layer.msg('修改成功');
                    // window.location='/mi/personal_center/personal_info';
                    // let update_img = document.getElementById("update_img");
                    // let headPic = document.getElementById("headPic");
                    // // alert(document.getElementById("imgSrc").value)
                    // update_img.src =  "" + res.data.userImg;
                    // headPic.src =  "" + res.data.userImg;
                    window.location = "/mi/personal_center/personal_info";
                }else if (res.code=='404'){
                    layer.msg('修改失败,昵称不能为空!');
                }
            })


    }

}

